public class Problem10 {
	public static void main(String[] args) {
		long sum = 0;
		long p = 2;
		int[] num = new int[2000001];
		for(int i = 1 ; i < num.length ; i ++ ) {
			num[i] = 1;
		}
		for(int i = 2 ; i < num.length ; i ++ ) {
			for(int j = 2*i ; j < num.length ; j += i) {
				num[j] = 0;
			}
		}
		for(int i = 2 ; i < num.length ; i ++ ) {
			if(num[i] == 1) {
				sum += i;
			}
		}
		System.out.println("" + sum);
	}

	private static long next_prime (long p) {
		long i = p + 1;
		long j = 2;
		while (true) {
			for (; j <= Math.sqrt(i); ++j) {
				if (i % j == 0)
					break;	
			}
			if (i % j == 0)
				continue;

			return i;
		}
	}
}
